import time
from time import sleep

from selenium.webdriver.support.select import Select

from Finance_fun.base.base import Base
from Finance_fun import page


class Page(Base):
    """以下为注册界面操作"""
    # 点击注册链接
    def page_click_register_link(self):
        self.base_click(page.register_link)

    # 输入注册手机号
    def page_input_register_phone(self, phone):
        self.base_input(page.register_phone, phone)

    # 获取登录手机号
    def page_get_register_phone(self):
        return self.base_get_text(page.register_phone)

    # 输入注册密码
    def page_input_register_password(self, password):
        self.base_input(page.register_password, password)

    # 输入注册验证码
    def page_input_register_verify_code(self, verify_code):
        self.base_input(page.register_verify_code, verify_code)

    # 点击获取验证码按钮
    def page_click_register_get_phone_code(self):
        self.base_click(page.register_get_phone_code)

    # 输入手机验证码
    def page_input_register_phone_code(self, phone_code):
        self.base_input(page.register_phone_code, phone_code)

    # 点击已阅读条款
    def page_click_register_read_terms(self):
        self.base_click(page.register_read_terms)

    # 点击注册按钮
    def page_click_register_btn(self):
        self.base_click(page.register_btn)

    # 获取注册成功提示信息
    def page_get_register_success_inf(self):
        return self.base_get_text(page.register_success)

    # 获取手机号为空或格式错误时的提示信息
    def page_get_register_phone_err_inf(self):
        return self.base_get_text(page.register_phone_error)

    # 获取密码为空或者格式错误时的提示信息
    def page_get_register_password_err_inf(self):
        return self.base_get_text(page.register_password_error)

    # 获取验证码为空或者格式错误时的提示信息
    def page_get_register_verify_code_err_inf(self):
        return self.base_get_text(page.register_verify_code_error)

    # # 获取手机验证码为空或者格式错误时的提示信息
    # def page_get_register_phone_code_err_inf(self):
    #     return self.base_get_text(page.register_phone_code_error)

    # 获取手机验证码为空或者格式错误时的提示信息
    def page_get_register_phone_code_err_alert(self):
        return self.base_get_text(page.register_alert)

    """截图操作"""
    def page_get_screenshot(self):
        self.base_get_image()

    # 集成注册操作
    def page_register(self, phone, password, verify_code, phone_code):
        # self.page_click_register_link()
        self.page_input_register_phone(phone)
        self.page_input_register_password(password)
        self.page_input_register_verify_code(verify_code)
        # # 获取登录手机号
        # if self.page_get_login_phone() != "":
        #     self.page_click_register_get_phone_code()
        self.page_click_register_get_phone_code()
        sleep(3)
        self.page_input_register_phone_code(phone_code)
        # self.page_click_register_read_terms()
        sleep(2)
        self.page_click_register_btn()

    # 集成注册操作不点击
    def page_register_no_click(self, phone, password, verify_code, phone_code):
        # self.page_click_register_link()
        self.page_input_register_phone(phone)
        self.page_input_register_password(password)
        self.page_input_register_verify_code(verify_code)
        sleep(3)
        self.page_input_register_phone_code(phone_code)
        # self.page_click_register_read_terms()
        sleep(2)
        self.page_click_register_btn()

    '''以下为我的推广的界面操作'''
    # 点击我的推广链接
    def click_my_promotion_link(self):
        self.base_click(page.my_promotion)

    # 我的推广输入框
    def input_my_promotion_search(self,msg):
        self.base_input(page.my_promotion_search,msg)

    # 点击搜索按钮
    def click_my_promotion_search_btn(self):
        self.base_click(page.my_promotion_search_btn)

    '''以下为推广记录的界面操作'''
    # 点击推广记录链接
    def click_promotion_record(self):
        self.base_click(page.promotion_record)

    # 输入起始时间
    def input_start_time_promotion(self,starttime):
        self.base_input(page.start_time_promotion,starttime)

    # 输入截止时间
    def input_end_time_promotion(self,endtime):
        self.base_input(page.end_time_promotion,endtime)

    # 输入用户名
    def input_username_promotion(self,username):
        self.base_input(page.input_username_promotion,username)

    # 点击搜索按钮
    def click_search_btn_promotion(self):
        self.base_click(page.click_search_promotion)